package com.example.electronicmall.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.electronicmall.R;
import com.example.electronicmall.bean.Docxbean;

import java.util.List;

/*
* 作者：王辉
* 功能：确认订单适配器
* 时间：2022//11/6
* */
public class DocxAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
private Context context;
private List<Docxbean> list;

    public DocxAdapter(Context context, List<Docxbean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull  ViewGroup parent, int viewType) {
        return new DocxAHolder(LayoutInflater.from(context).inflate(R.layout.docx_item_list,null));
    }

    @Override
    public void onBindViewHolder(@NonNull  RecyclerView.ViewHolder holder, int position) {
        ((DocxAHolder)holder).docxshopicon.setImageBitmap(list.get(position).getDocxicon());
        ((DocxAHolder)holder).docxshopname.setText(list.get(position).getDocxname());
        ((DocxAHolder)holder).docxshopsku.setText(list.get(position).getSku());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class DocxAHolder extends RecyclerView.ViewHolder {
        TextView docxshopname,docxshopsku;
        ImageView docxshopicon;
         public DocxAHolder(@NonNull  View itemView) {
             super(itemView);
             docxshopname=itemView.findViewById(R.id.docx_item_shopsname);
             docxshopsku=itemView.findViewById(R.id.docx_item_sku);
             docxshopicon=itemView.findViewById(R.id.docx_item_shopsicon);
         }

     }
}
